import type LogicFlow from '@logicflow/core';
import type { Control } from '@logicflow/extension';

export function configDefaultDndPanel(lf: LogicFlow) {
  return [
    {
      text: '选区',
      icon: '',
      callback: () => {
        lf.updateEditConfig({
          stopMoveGraph: true,
        });
      },
    },
    {
      type: 'circle',
      text: '开始',
      icon: '',
    },
    {
      type: 'rect',
      text: '用户任务',
      icon: '',
      cls: 'important-node',
    },
    {
      type: 'rect',
      text: '系统任务',
      icon: '',
      cls: 'import_icon',
    },
    {
      type: 'diamond',
      text: '条件判断',
      icon: '',
    },
    {
      type: 'circle',
      text: '结束',
      icon: '',
    },
  ];
}

export function configAddItemControl(lf: LogicFlow) {
  console.log(lf.extension);
  (lf.extension.control as Control).addItem({
    key: 'download',
    iconClass: 'lf-control-redo',
    title: '下载',
    text: '下载',
    onClick: (lf: LogicFlow, _ev: MouseEvent) => {
      lf.getSnapshot();
    },
  });
}
